package com.diver.flinkdemo.entity;

/**
 * Created with IntelliJ IDEA.
 *
 * @Description: 通用返回对象
 * @Author: zhangB
 * @Date: 2021/12/21 15:04
 */
public class ResultConfig<T> {

    public static final int SUCCESS_CODE = 200;//成功
    public static final int REQUEST_ERROR_CODE = 400;//请求参数错误
    public static final int SERVICE_ERROR_CODE = 420;//业务操作失败
    public static final int EXCEPTION_CODE = 402;//处理发生异常
    public static final String EXCEPTION_MSG = "内部错误";
    public static final String SUCCESS_MSG = "SUCCESS";

    private int resultCode;//状态码
    private String msg;//通知信息
    private T resultData;//返回的数据

    private ResultConfig(int resultCode, String msg, T resultData){
        this. resultCode = resultCode;
        this.msg = msg;
        this.resultData = resultData;
    }
    private ResultConfig(){}
    public int getResultCode() {
        return resultCode;
    }

    public void setResultCode(int resultCode) {
        this.resultCode = resultCode;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getResultData() {
        return resultData;
    }

    public void setResultData(T resultData) {
        this.resultData = resultData;
    }

    public static <T>ResultConfig<T> getInstance(int resultCode,String msg,T data){
        return new ResultConfig<T>(resultCode,msg,data);
    }
    public static ResultConfig getInstance(){
        return new ResultConfig();
    }

    @Override
    public String toString() {
        return "ResultConfig{" +
                "resultCode=" + resultCode +
                ", msg='" + msg + '\'' +
                ", resultData=" + resultData +
                '}';
    }

}
